<%@ page language="java" import="java.util.*" import="java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线点餐系统管理平台</title>
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath }/admin/css/invalid.css" type="text/css" media="screen" />
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/facebox.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/admin/scripts/jquery.date.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/common.js"></script>
<script type='text/javascript' src='${pageContext.request.contextPath }/dwr/interface/foodMng.js'></script>
<script type='text/javascript' src='${pageContext.request.contextPath }/dwr/engine.js'></script>
<script type="text/javascript">
function chkInput(obj){
	if(obj.value.Trim()==""){
		document.getElementById(obj.id+"Span").className="input-notification error png_bg";
		document.getElementById(obj.id+"Span").innerText="请填写";
	}else{
		document.getElementById(obj.id+"Span").className="input-notification success png_bg";
		document.getElementById(obj.id+"Span").innerText="";
	}
}
function chkName(obj){
	if(obj.value.Trim()==""){
		document.getElementById(obj.id+"Span").className="input-notification error png_bg";
		document.getElementById(obj.id+"Span").innerText="请填写";
	}else{
		foodMng.isExistFoodName(obj.value, function(data){
			if(data){
				document.getElementById(obj.id+"Span").className="input-notification error png_bg";
				document.getElementById(obj.id+"Span").innerText="该名称已存在，请确定名称是否正确";
			}else{
				document.getElementById(obj.id+"Span").className="input-notification success png_bg";
				document.getElementById(obj.id+"Span").innerText="";
			}
		});
	}
}
</script>
</head>
<body>
  <%-- 加载左边菜单 --%>
  <s:include value="../main/left.jsp?mid=m21"></s:include>
  
	<div class="clear"></div>
  <div id="main-content">
    <!-- Box Content -->
    <div class="content-box">
    	<!-- Box Header -->
      <div class="content-box-header">
        <h3>添加商品信息</h3>
        <div class="clear"></div>
      </div>
      <!-- End Box Header -->
      
      <!-- 信息提示 -->
      <s:if test="#request.fieldErrors.size>0">
      <div class="notification error png_bg"><a href="#" class="close"><img src="${pageContext.request.contextPath }/admin/images/icons/cross_grey_small.png" title="关闭" alt="关闭" /></a>
      	<div><s:fielderror/></div>
      </div>
      </s:if>
			<s:if test="#request.actionMessages.size>0">
			<div class="notification error png_bg"><a href="#" class="close"><img src="${pageContext.request.contextPath }/admin/images/icons/cross_grey_small.png" title="关闭" alt="关闭" /></a>
				<div><s:actionmessage/></div>
			</div>
			</s:if>
			<!-- 信息提示结束 -->
			
			<!-- Table Content -->
      <div class="tab-content">
        <s:form action="foodManager_add" method="post" enctype="multipart/form-data" namespace="/admin">
        	<fieldset>
          <p>
          	<label>商品名称</label>
            <s:textfield cssClass="text-input small-input" id="foodName" name="food.name" onblur="chkName(this)"/>
            <span id="foodNameSpan"></span>
            <br />
          	<small>必填</small>
          </p>
          
          <p>
          	<label>商品描述</label>
            <s:textfield cssClass="text-input large-input" name="food.description"/>
          </p>
          
          <p>
          	<label>单价</label>
            <s:textfield cssClass="text-input small-input" id="price" name="food.price"/>
          	<small>必填,只能是整数或小数,如:10.5</small>
          </p>
          
            <p>
          	<label>是否推荐 / 优惠</label>
           <input type="radio" onclick="$('#yh').hide(500);$('input[name=food.favPrice]').val('')" name="food.foodClass" value="1" checked="checked"/>一&nbsp;&nbsp;般&nbsp;&nbsp;<input type="radio" onclick="$('#yh').hide(500);$('input[name=food.favPrice]').val('')" name="food.foodClass" value="2"/>推&nbsp;&nbsp;荐&nbsp;&nbsp; <input type="radio" onclick="$('#yh').show(500)" name="food.foodClass" value="3" />优&nbsp;&nbsp;惠
          	<div style="heigth:20px;display:none; " id="yh"><input type="text" name="food.favPrice" style="border-radius: 4px 4px 4px 4px;border:1px solid  rgb(213, 213, 213);padding:4px;" value="" /><small> 必填,只能是整数或小数,如:10.5</small></div>
          </p>
          
          <p>
            <label>类别</label>
            <s:select name="food.foodType.id" list="foodtypelist" cssClass="small-input" listKey="id" listValue="name"  headerKey="0"/>
          </p>
            
          <p>
            <label>商品状态</label>
            <input type="radio" name="food.state" value="1" checked="checked"/>正&nbsp;&nbsp;常<input type="radio" name="food.state" value="2"/>下&nbsp;&nbsp;架
          </p>
          
          <p>
            <label>上传图片</label>
            <s:file name="foodPic"></s:file>
          </p>
          <input name="food.addTime" type="hidden" value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) %>" />
          <p><input class="button" type="submit" value="提  交" /></p>
          </fieldset>
        </s:form>
      </div>
     
      <!-- End Table Content -->
     </div>
     
     <!-- End Box Content -->
  
	<div class="clear"></div>
	<%-- 加载底部 --%>
	<s:include value="../main/footer.jsp"></s:include>
	</div>
</body>
</html>

